//
//  WDNetworkManager.m
//  Pods
//
//  Created by Alean on 2022/12/1.
//

#import "WDNetworkManager.h"

@implementation WDNetworkManager

+ (instancetype)shareInstance {
    static dispatch_once_t onceToken;
    static WDNetworkManager *instance = nil;
    dispatch_once(&onceToken, ^{
        instance = [[super allocWithZone:NULL] init];
    });
    return instance ;
}

+ (id)allocWithZone:(struct _NSZone *)zone {
    return [WDNetworkManager shareInstance];
}

- (id)copyWithZone:(struct _NSZone *)zone{
    return [WDNetworkManager shareInstance];
}

- (instancetype)init {
    self = [super init];
    if (self) {
    }
    return self;
}

+ (WDNetworkRequestObject *)sendGetRequestWithPath:(NSString *)path
                                        paremeters:(NSDictionary *)parameters
                                           success:(SuccessBlock)successBlock
                                           failure:(FailureBlock)failuerBlock {
    WDNetworkRequestObject *op = [WDNetworkRequestObject new];
    [op sendRequestWithPath:path method:RequestMethodGet parameters:parameters success:successBlock failure:failuerBlock];
    return op;
}

+ (WDNetworkRequestObject *)sendPostRequestWithPath:(NSString *)path
                                         paremeters:(NSDictionary *)parameters
                                            success:(SuccessBlock)successBlock
                                            failure:(FailureBlock)failuerBlock {
    WDNetworkRequestObject *op = [WDNetworkRequestObject new];
    [op sendRequestWithPath:path method:RequestMethodPost parameters:parameters success:successBlock failure:failuerBlock];
    return op;
}

+ (WDNetworkRequestObject *)sendPostRequestWithPath:(NSString *)path
                                         paremeters:(NSDictionary *)parameters
                          constructingBodyWithBlock:(void (^)(id<AFMultipartFormData> _Nonnull))block
                                            success:(SuccessBlock)successBlock
                                            failure:(FailureBlock)failuerBlock {
    WDNetworkRequestObject *op = [WDNetworkRequestObject new];
    [op sendPostRequestWithPath:path paremeters:parameters constructingBodyWithBlock:block success:successBlock failure:failuerBlock];
    return op;
}

@end
